﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;

namespace NJL.WebMembers.Handle
{
    public partial class UploadFile1 : System.Web.UI.Page
    {
        protected void Page_Load(object sender, EventArgs e)
        {
            BasePageVisitor basePage = new BasePageVisitor();
            NJL.BLL.NJL_PERSON bllPerson = new BLL.NJL_PERSON();
            NJL.Model.NJL_PERSON modelPerson = bllPerson.GetModelByUserId(basePage.UserId);
            if (Request.Files.Count > 0)
            {
                basePage.DeleteImageByCode(modelPerson.IMAGE_CODE);
                string id = basePage.SaveUploadFile(Request.Files);
                if (!string.IsNullOrEmpty(id))
                {
                    modelPerson.IMAGE_CODE = id;
                    if (bllPerson.Update(modelPerson))
                    {
                        Response.Write("<div id=\"successUpload\"><script>window.parent.userinfoTab('divuserHeadInfo');window.parent.loadUserHead();</script></div>");
                    }
                    else
                    {
                        Response.Write("false");
                    }
                }
            }
        }
    }
}